import re
log = 'Sep 26 2021 23:11:02-08:00 Layer3Switch-1 L2IFPPI/4/MFLPVLANALARM:OID 1.3.6.1.4.1.2011.5.25.160.3.7 MAC move detected, VlanId = 54, MacAddress = 0000-5e00-0136, Original-Port = GE0/0/1, Flapping port = GE0/0/2. Please check the network accessed to flapping port.'

# log = 'Sep 26 2021 23:11:02-08:00 Layer3Switch-1 L2IFPPI/4/MFLPVLANALARM:OID 1.3.6.1.4.1.2011.5.25.160.3.7 MAC move detected, VlanId = (\d+), MacAddress = \S+, Original-Port = (\S+), Flapping port = (\S+)\. Please check the network accessed to flapping port.'
#match=re.search(r'VlanId = (\d+), MacAddress = \S+, Original-Port = (\S+), Flapping port = (\S+)\.',log)

# print(match.groups())
regex=(r'VlanId = (\d+), MacAddress = \S+, Original-Port = (\S+), Flapping port = (\S+)\.')

ports=set()

with open(r'c:\tools\log.txt') as f:
	for line in f:
		print(line.strip())
		match=re.search(regex,line)
		if match:
			vlan=match.group(1)
			ports.add(match.group(2))
			ports.add(match.group(3))

print('Loop between ports {} in VLAN {}'.format(', '.join(ports),vlan))